import {Alias, Children, Column, Editor, Enum, Serialize, Sort} from "../../decorator";
import {Element} from "../../element";

export enum PropertyType {
    Text = "text",
    Number = "number",
    Date = "date"
}

export enum PropertySelectMode {
    Default = "default",
    Multiple = "multiple"
}

export class Property extends Element{

    @Editor("String")
    @Alias("属性别名")
    @Column()
    @Serialize()
    public alias: string = "";

    @Editor("Enum")
    @Enum(PropertyType)
    @Alias("数据类型")
    @Serialize()
    public type: PropertyType = PropertyType.Text;

    @Editor("String")
    @Alias("属性单位")
    @Serialize()
    public unit: string = "";

    @Editor("Boolean")
    @Alias("必填属性")
    @Serialize()
    public required: boolean = false;

    @Editor("Boolean")
    @Alias("主要属性")
    @Serialize()
    public major: boolean = false;

    @Editor("Boolean")
    @Alias("是否枚举")
    @Serialize()
    public select: boolean = false;

    @Editor("Enum")
    @Enum(PropertySelectMode)
    @Alias("枚举类型")
    @Serialize()
    public select_mode: PropertySelectMode = PropertySelectMode.Default;

    @Editor("String")
    @Alias("所属组别")
    @Serialize()
    public group: string = "";

    @Column()
    @Sort()
    @Editor("Number")
    @Alias("序号")
    @Serialize()
    public order: number = 0;

    @Editor("List")
    @Children(String)
    @Alias("枚举选项")
    @Serialize()
    public options: Array<string> = [];

    public value: any;

    constructor() {
        super();
    }

}
